home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / CUCD / Magazine / C_Tutorial / Part-9 / wb1 / drawwin.c < prev    next >
C/C++ Source or Header  |  1997-10-27  |  2KB  |  63 lines

  1. #include "drawwin.h"
  2. #include "bitmap.h"
  3. #include "gadgets.h"
  4. #include "menu.h"
  5. #include "screen.h"
  6.  
  7. #include<graphics/rastport.h>
  8.  
  9. #include<stdio.h>
  10.  
  11. #include<clib/graphics_protos.h>
  12. #include<clib/intuition_protos.h>
  13.  
  14. /* Global record of our tool window */
  15. struct Window* drawwin = NULL;
  16.  
  17. int openDrawWin()
  18. {
  19.     struct Screen* scr = getScreen();
  20.     /* Open our drawing window */
  21.     if(drawwin = OpenWindowTags(NULL,
  22.                                                             WA_Left,                    0,
  23.                                                             WA_Top,                        0,
  24.                                                             /* Make the window the same size as the screen */
  25.                                                             WA_Width,                    scr->Width,
  26.                                                             WA_Height,                scr->Height,
  27.                                                             WA_Flags,                    WFLG_BACKDROP | WFLG_BORDERLESS | WFLG_REPORTMOUSE | WFLG_SUPER_BITMAP,
  28.                                                             WA_IDCMP,                    IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE | IDCMP_MENUPICK,
  29.                                                             WA_CustomScreen,    scr,
  30.                                                             WA_SuperBitMap,        getBitmap(),
  31.                                                             TAG_DONE,                    0))
  32.     {
  33.         /* Clear our window, since our new bitmap may not be cleared already */
  34.         SetRast(drawwin->RPort, 0);
  35.         /* Set the drawing mode to draw only the foreground of text, not the background */
  36.         SetDrMd(drawwin->RPort, JAM1);
  37.         resetFgPen(drawwin);
  38.         /* Attach menu strip to drawing window */
  39.         if(SetMenuStrip(drawwin, getMenuStrip()))
  40.             return TRUE;
  41.         else
  42.             printf("Error: could not attach menus to drawing window\n");
  43.     }
  44.     else
  45.         printf("Error: could not open drawing window\n");
  46.     return FALSE;
  47. }
  48.  
  49. void closeDrawWin()
  50. {
  51.     if(drawwin)
  52.     {
  53.         ClearMenuStrip(drawwin);
  54.         CloseWindow(drawwin);
  55.         drawwin = NULL;
  56.     }
  57. }
  58.  
  59. struct Window* getDrawWin()
  60. {
  61.     return drawwin;
  62. }
  63.